package com.v5.mr.combiner.wc;

import java.io.IOException;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

//                                              k3     v3          k4       v4
public class WordCountReducer extends Reducer<Text, LongWritable, Text, LongWritable> {

	@Override
	protected void reduce(Text k3, Iterable<LongWritable> v3,Context context) throws IOException, InterruptedException {
		/*
		 * context 代表Reducer上下文
		 * 上文：mapper
		 * 下文：HDFS
		 */
		long total = 0;
		for(LongWritable l:v3){
			total = total + l.get();
		}
		
		//输出  k4     v4
		context.write(k3, new LongWritable(total));
	}
}
